﻿using UnityEngine;



public class ResourceManager : Singleton<ResourceManager>
{
    private static string strAssetPath;

    public ResourceManager()
    {
        Init();
    }
    void Init()
    {
        Caching.ClearCache();

        strAssetPath =
#if UNITY_STANDALONE_WIN || UNITY_EDITOR
            Application.streamingAssetsPath;
#elif UNITY_ANDROID
			Application.persistentDataPath;
#elif UNITY_IPHONE
			Application.streamingAssetsPath;
#else
			Application.streamingAssetsPath;
#endif

    }

    public string GetAssertPath()
    {
        return strAssetPath;
    }

    public Object LoadResource(string strPath)
    {
        UnityEngine.Object res = Resources.Load(strPath); ;
        return res;
    }

    public GameObject LoadPrefab(string path,bool needInstantiated = true)
    {
        GameObject res = LoadResource(path) as GameObject;
        if (!needInstantiated) return res;
        if (res == null)
        {
            Debug.LogError(string.Format("LoadPrfab Error In Path : {0}",path));
            return null;
        }
        return Object.Instantiate(res);
    }


}
